package com.graphhopper.util.buffer;


import org.locationtech.jts.geom.Coordinate;
import org.locationtech.jts.geom.Envelope;
import org.locationtech.jts.geom.Geometry;
import org.locationtech.jts.operation.buffer.BufferOp;

/**
 * 矩形缓冲区域实现类
 * @author: heguanglong
 * @date: 2020-12-26
 **/
public class EnvelopeBufferImpl extends BufferBase implements BufferStrategy {
    @Override
    public String addBuffer(String gps, double rd) {
        Coordinate[] coordinates4= getCoordinate(gps);
        Envelope envelope = new Envelope(coordinates4[0].x,coordinates4[1].x,coordinates4[0].y,coordinates4[1].y);
        Geometry buffer = getBuff(geometryFactory.toGeometry(envelope), BufferOp.CAP_SQUARE, rd);
        Envelope temp=buffer.getEnvelopeInternal();
        double db=(rd*rate)/baseNum;
        return (temp.getMinX()-db)+","+temp.getMinY()+";"+(temp.getMaxX()+db)+","+temp.getMaxY();
    }

    @Override
    public String geometryInfo(String gps, double rd) {
        Coordinate[] coordinates4= getCoordinate(gps);
        Envelope envelope = new Envelope(coordinates4[0].x,coordinates4[1].x,coordinates4[0].y,coordinates4[1].y);
        Geometry buffer = getBuff(geometryFactory.toGeometry(envelope), BufferOp.CAP_SQUARE, rd);
        return buffer.toString();
    }

    @Override
    public Geometry geometry(String gps) {

        return null;
    }
}
